package com.subsequent.controller;

import com.subsequent.service.ServiceTypesService;
import com.subsequent.vo.ServiceTypeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/serviceTypes")
public class ServiceTypesController {
    @Autowired
    private ServiceTypesService serviceTypesService;

    @GetMapping("/list")
    public List<ServiceTypeVO> list(
            @RequestParam(required = false) String name,
            @RequestParam(required = false) String status,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime
    ) {
        return serviceTypesService.list(name, status, startTime, endTime);
    }
}